var Modal = require('./index');

function _Alert(opts){
	var _alert=new Modal({
		type:opts.type,
		top:opts.top,
		left:opts.left,
		right:opts.right,
		width:opts.width,
		height:opts.height,
		yes:opts.yes,
		no:opts.no,
		yesText:opts.yesText,
		noText:opts.noText,
		onOK:opts.onOK,
		delayAutoClose:opts.delayAutoClose,
		autoDelete:true,
		onShow:function(){
			opts.onShow&&opts.onShow();
		},
		onClose:function(){
			opts.onClose&&opts.onClose();
			_alert.delete();
		},
		innerHTML:`
			<div class="yss-layer-mess">
			<div class="yss-layer-mess-bd">
				<i class="iconfont icon-${opts.type} fl"></i>
				<p class="p">${opts.content}</p>
			</div>
			</div>
		`
	});
	_alert.show();
}

var Message = function(){
	var mess={
		info:'info',
		error:'error',
		success:'success'
	}
	for(var _type in mess){
		mess[_type]=function(_type){
			return function(opts){
				_Alert({
					type:_type,
					top:opts.top,
					left:opts.left,
					right:opts.right,
					width:opts.width,
					height:'auto',
					content:opts.content,
					yes:opts.yes,
					no:opts.no,
					yesText:opts.yesText,
					noText:opts.noText,
					delayAutoClose:opts.delayAutoClose,
					onOK:opts.onOK,
					onClose:opts.onClose
				});
			}
		}(_type);
	}
	return mess;
}();
	
module.exports = Message;